<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ESP12F固件上传</title>
    <script language="javascript">
        function config() {
            var ssid = configForm.ssid.value;
            var password = configForm.password.value;
            if (('' == ssid) && ('' == password)) {
                alert('[WiFi名称、WiFi密码]，必须填写!');
                return;
            }

            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET", "/config?ssid=" + ssid + "&password=" + password, true);
            xmlhttp.send();
            alert('已提交，保存后设备会自动重启!');
        }
    </script>
</head>

<body>
    <p>ESP12S网页配网</p>
    <form name="configForm">
        WiFi名称:
        <input type="text" name="ssid" placeholder="请输入WiFi名称,留空不设置" value="{ssid}">
        <br>
        WiFi密码:
        <input type="text" name="password" placeholder="请输入WiFi密码,留空不设置" value="{password}">
        <br>
        <input type="button" value="确定" onclick="config()">
    </form>

    <br><br>
    <hr>
    <form method='POST' action='/update' enctype='multipart/form-data'>
        固件:<br>
        <input type='file' accept='.bin,.bin.gz' name='firmware'>
        <input type='submit' value='升级固件'>
    </form>

    <br><br>
    <hr>
    <form method='POST' action='/update' enctype='multipart/form-data'>
        文件系统:<br>
        <input type='file' accept='.bin,.bin.gz' name='filesystem'>
        <input type='submit' value='升级文件系统'>
    </form>
</body>
</html>